package com.sugar.psych.assessment.module.business.dal.mysql.usertreeholeclock;

import java.util.*;

import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.psych.assessment.module.business.controller.admin.userpointsrecord.vo.UserPointsRecordRespVO;
import com.sugar.psych.assessment.module.business.dal.dataobject.user.UserDO;
import com.sugar.psych.assessment.module.business.dal.dataobject.userpointsrecord.UserPointsRecordDO;
import com.sugar.psych.assessment.module.business.dal.dataobject.usertreeholeclock.UserTreeHoleClockDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.psych.assessment.module.business.controller.admin.usertreeholeclock.vo.*;

/**
 * 树洞打卡 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface UserTreeHoleClockMapper extends BaseMapperX<UserTreeHoleClockDO> {

    default PageResult<UserTreeHoleClockRespVO> selectPage(UserTreeHoleClockPageReqVO reqVO) {
        return selectJoinPage(reqVO, UserTreeHoleClockRespVO.class, new MPJLambdaWrapperX<UserTreeHoleClockDO>()
                .selectAll(UserTreeHoleClockDO.class)
                .selectAs(UserDO::getNickname, UserTreeHoleClockRespVO::getNickname)
                .selectAs(UserDO::getMobile, UserTreeHoleClockRespVO::getMobile)
                .leftJoin(UserDO.class, UserDO::getId, UserTreeHoleClockDO::getUserId)
                .eqIfPresent(UserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(UserTreeHoleClockDO::getType, reqVO.getType())
                .betweenIfPresent(UserTreeHoleClockDO::getClockTime, reqVO.getClockTime())
                .betweenIfPresent(UserTreeHoleClockDO::getCreateDate, reqVO.getCreateDate())
                .eqIfPresent(UserTreeHoleClockDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(UserTreeHoleClockDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserTreeHoleClockDO::getId));
    }

}